package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsRegion;
import com.qf.service.RegionService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * projectName: shop-manage
 *
 * @author: 元
 * time: 2021/9/16 0016 17:23
 * description:行政区域列表接口
 */
@RestController
@CrossOrigin("*")
@RequestMapping("region")
public class AdminRegionController {

    @Autowired
    private RegionService regionService;

    @RequestMapping("list")
    public Object list(Integer page,Integer limit,String name,Integer code){
        IPage<DtsRegion> regionIPage = regionService.selectByPage(page,limit,name,code);
        Map <String,Object> data = new HashMap<>();
        data.put("total",regionIPage.getTotal());
        data.put("items",regionIPage.getRecords());
        return ResponseUtil.ok(data);

    }

}
